package com.jyy.prefabricated.controller;

import com.jyy.prefabricated.common.AjaxResult;
import com.jyy.prefabricated.dto.AnswerDto;
import com.jyy.prefabricated.entity.StudentQuizQuestion;
import com.jyy.prefabricated.service.StudentQuizQuestionService;
import com.jyy.prefabricated.vo.StudentExercisePaperVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 学生随堂考试题表(StudentQuizQuestion)表控制层
 *
 * @author makejava
 * @since 2021-10-11 13:49:18
 */
@RestController
@RequestMapping("/api")
public class StudentQuizQuestionController {
    /**
     * 服务对象
     */
    @Resource
    private StudentQuizQuestionService studentQuizQuestionService;


    /**
     * 随堂考答题
     * @param dto
     * @return
     */
    @PutMapping("/student-quiz-question")
    public AjaxResult update(@Valid @RequestBody AnswerDto dto){
        StudentExercisePaperVo result = studentQuizQuestionService.answer(dto);
        return AjaxResult.success(result);
    }


    /**
     * 获取随堂考试题
     * @param studentQuizId 学生随堂考id
     * @return
     */
    @GetMapping("/student-quiz-question/{studentQuizId}")
    public AjaxResult selectById(@PathVariable Integer studentQuizId){
        StudentExercisePaperVo result = studentQuizQuestionService.fetchQuestionsByStudentQuizId(studentQuizId);
        return AjaxResult.success(result);
    }
}
